<?  
	if(isset($_POST['btnsubmit']))
	{
		require("required/dbconnect.php"); 
		require("required/function.php"); 
		
		$photo_id=$_POST['photo_id'];
		$id=$_POST['id'];
		$get_photo=mysql_query("select name from os_productpic where id=$photo_id");
		$photo_name=mysql_result($get_photo,0,'name');
		$file_l = "../productpic/$photo_name";
		$file_s = "../productpic/thumbnails/$photo_name";
		unlink($file_l);
		unlink($file_s);
		$delete=mysql_query("delete from os_productpic where id=$photo_id");
		header("Location:product_viewfull.php?updated=4&id=$id");
	
	}
	
	$title="Delete photo"; 
	$pageid="3";
	$accessid="a00";

	require("required/dbconnect.php"); 
	require("required/function.php");
	require("required/header.php");
	
	

	$photo_id=$_GET['pid'];
	$id=$_GET['aid'];
	$errormsg="";
	
	$get_photo=mysql_fetch_array(mysql_query("select * from os_productpic where id=$photo_id"),MYSQL_ASSOC);
	
		
	if($get_photo["width"]>300 or $get_photo["height"]>250)
	{
		if($get_photo["width"]-$get_photo["height"]>0)
		{
			$pfix="width=300";
			
		}
		else
		{
			$pfix="height=250";
			
		}						
	}
	else
	{
		$pfix="";
		
	}
	
	
?>
<table width="100%"  cellpadding="0" cellspacing="5" height="300">
				<script language="JavaScript" type="text/javascript" src="wysiwyg.js">
				</script>
				
			<td width="84%" align="left" valign="top">
<table width="95%" cellpadding="2" cellspacing="1">
	
	<td width="100%" valign="top">
		<table width="100%">
  	 	<tr>
			<td class="title">Delete photo</td>
		</tr>
		<tr>
			<td align="center">
				
				<img src="../productpic/<?= $get_photo['name'] ?>" <?= $pfix ?>> <br><?= $get_photo['caption'] ?>
				
			</td>
		</tr>
    <form method="post" action="<?= $_SERVER['PHP_SELF'] ?>">
		<tr>
			<td align="center">
			  <input type="hidden" name="photo_id" value="<?= $photo_id ?>">
			   <input type="hidden" name="id" value="<?= $id ?>">
			  Confirm to delete this image? <br>
			  <input type="submit" value="Yes" class=button name="btnsubmit"> <input type="button" value="back" onclick="history.go(-1)" class=button> 
			 </td>
		</tr>
	</form>
  </table><br>
</td>
</table>
</td>

</table>

<? require("required/footer.php") ?>
	

